package com.macro.mall.remote;

import com.macro.mall.common.api.CommonResult;
import com.macro.mall.common.domain.EsDocDto;
import com.macro.mall.common.domain.EsIndexDto;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient("mall-es")
public interface AdminRemote {
    /**
     * 判断索引是否存在
     * @param indexName 索引名称
     * @return
     */
    @GetMapping("/index/exists")
    public CommonResult exists(@RequestParam @NotEmpty(message = "索引名称不能为空") String indexName);

    /**
     * 创建索引的接口
     * @param esIndexDto 索引信息
     * @return
     */
    @PostMapping("/index/create")
    public CommonResult createIndex(@Validated @RequestBody EsIndexDto esIndexDto);
    /**
     * 批量插入
     * @param indexInfoDto
     * @return
     */
    @PostMapping("/doc/batchSave")
    public CommonResult batchSave(@RequestBody EsDocDto indexInfoDto);

    /**
     * 批量删除
     * @param indexName
     * @param ids
     * @return
     */
    @DeleteMapping("/doc/batchDelete")
    public CommonResult batchDelete(@RequestParam("indexName")@NotNull(message = "索引名称不能为空")String indexName, @RequestParam("idField") List<String> ids);
}
